package com.openbravo.pos.reports;

import com.openbravo.basic.BasicException;
import com.openbravo.data.loader.BaseSentence;
import com.openbravo.data.loader.DataResultSet;
import com.openbravo.pos.forms.AppLocal;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

public class JRDataSourceBasic
  implements JRDataSource
{
  private BaseSentence sent;
  private DataResultSet SRS = null;
  private Object current = null;
  private ReportFields m_fields = null;

  public JRDataSourceBasic(BaseSentence paramBaseSentence, ReportFields paramReportFields, Object paramObject)
    throws BasicException
  {
    this.sent = paramBaseSentence;
    this.SRS = paramBaseSentence.openExec(paramObject);
    this.m_fields = paramReportFields;
  }

  public Object getFieldValue(JRField paramJRField)
    throws JRException
  {
    try
    {
      return this.m_fields.getField(this.current, paramJRField.getName());
    }
    catch (ReportException localReportException)
    {  throw new JRException(localReportException);
    }
  
  }

  public boolean next()
    throws JRException
  {
    if (this.SRS == null)
      throw new JRException(AppLocal.getIntString("exception.unavailabledataset"));
    try
    {
      if (this.SRS.next())
      {
        this.current = this.SRS.getCurrent();
        return true;
      }
      this.current = null;
      this.SRS = null;
      this.sent.closeExec();
      this.sent = null;
      return false;
    }
    catch (BasicException localBasicException)
    {  throw new JRException(localBasicException);
    }
  
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.reports.JRDataSourceBasic
 * JD-Core Version:    0.6.0
 */